Skip to content

agents: honor the configured OpenAI Functions output key - #1574

Open
Reason07 wants to merge 1 commit into
tmc:mainfrom
Reason07:fix/openai-functions-output-key
Open

Reason07 wants to merge 1 commit into
tmc:mainfrom
Reason07:fix/openai-functions-output-key

Conversation

@Reason07

@Reason07 Reason07 commented Nov 21, 2026 •

Copy link
Copy Markdown

NewOpenAIFunctionsAgent(..., agents.WithOutputKey("answer")) declares answer as its output key, but text completions are always returned under output. Consequently, a successful generation through chains.Run(ctx, agents.NewExecutor(agent), ...) fails with missing key in output values: answer.

Return the final answer under the configured output key, matching GetOutputKeys and the other agent implementations. Regression tests cover the default and custom keys through both ParseOutput and the public constructor/executor path, using the existing fake LLM without API calls.

Validation on Go 1.26.0 / Windows:

  • On unchanged main, both custom-key regression cases fail while the default-key controls pass. With the fix, all four cases pass.
  • go test -race ./agents ./chains ./memory ./prompts ./outputparser ./llms/fake -count=1: agents, memory, prompts, outputparser, and fake pass; six existing recorded OpenAI chains tests report network errors.
  • go vet on those six packages passes. Configured golangci-lint run ./agents --new-from-rev HEAD reports 0 issues; gofmt and git diff --check pass for the two changed files. Unfiltered agent lint reports four findings in unchanged files: three formatting findings from this CRLF checkout and QF1012 in mrkl_prompt.go.
  • Full checks were attempted. Repository lint exceeded its 5-minute package-load deadline. Repository tests encountered recorded-provider failures, an unavailable local LLM/Docker service, and a Milvus dependency that does not compile on Windows; that run was interrupted after recording these failures. Full-suite success is not claimed.

Implemented, tested, and reviewed with AI assistance.

CI note: the current govulncheck job flags the existing github.com/klauspost/compress@v1.19.2 (GO-2026-6865, published November 5), golang.org/x/net@v0.60.0 (GO-2026-6860, October 27), and Go 1.26.10 standard library (GO-2026-6859, November 11). This PR leaves go.mod, go.sum, and the CI workflow unchanged. The exact base CI run passed on October 22, before these advisories were published; that historical pass does not establish a clean scan against today's database.
Remote CI on ca8d862 has now passed lint, the full build, ordinary tests, race tests, coverage, and all 77 example builds. The govulncheck report described above is the only failing check.

Dependency follow-up: #1575 updates compress and x/net for the two third-party advisories. The existing #1571 Go upgrade covers the standard-library finding. These changes are reviewed separately from this OutputKey fix.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant